<?php
    date_default_timezone_set('UTC');
?>
<div class="well" >
    <div class="row-fluid centrar">
        <h3>Cuentas de banco</h3>
        <input type="hidden" name="id" value=""/>
    </div><br/>
    <div class="contenido contexto">
        <div id="grid"></div>
    </div>
    <br/>      
</div>

<script type="text/javascript">
    $(document).ready(function(){
 
    		
    	var dsGrid = new kendo.data.DataSource({
            type: "json",
            transport: {
                read: {
                        url: "<?php echo $view->url(array('controller' => 'BankAccounts', 'action' => 'getListBankAccount')); ?>",
                        dataType: "Json",
                        type: "POST"
                },
                create: {
                    url: "<?php echo $view->url(array('controller' => 'BankAccounts', 'action' => 'saveBankAccount')); ?>",
                    dataType: "Json",
                    type: "POST"
                }
            }, 
            schema: {
                model: {
                    id: "idBank",
                    fields: {
                    		idBank:{type:"number",editable:false},
                    		mail: { type: "string" },
 	                        name: { type: "string" },
	                        number: { type: "number" },
	                        clabe: {type:"number"},
	                        numbranch: {type:"number"},
	                        balance:{type:"number"},
	                        upgrade:{type:"Date",editable:false},
	                        comments: { type: "string" }
		             }
                }
            },
            pageSize: 10
        });

        $("#grid").kendoGrid({
            dataSource: dsGrid,
            height: 430,
            scrollable: true,
            filterable: {
                extra: false
            },
			toolbar: [{name:"create", text:"Nuevo Registro"}],
                pageable: {
                refresh: true,
                pageSizes: true,
                buttonCount: 10
            },
            selectable: "row",
            columns: [
                 { hidden: true, field: "idBank", title:"ID", width:"50px" },
                 { field: "name", title: "Banco", width: "150px" },
                { field: "number", title: "Numero de Cuenta", width: "150px" },
                { field: "clabe", title: "Clave de Cuenta", width: "130px" },
                { field: "numbranch", title: "Numero de Sucursal", width: "130px" },
                { field: "balance", title: "Balance", width: "120px" },
                { field: "upgrade", title: "Actualizacion", format: "{0: dd/MM/yyyy}", width: "150px" },
                { field: "comments", title: "Comentarios", width: "130px" },
                { command: [{name:"edit", text:"Editar"}, {name:"destroy", text:"Eliminar"}], title: "&nbsp;", width: "250px" }            
              ],
		        editable: "popup"
        });
        
        kendo.bind($(".contexto"), viewModel);
    });

  </script>